﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class FPSDisplay : MonoBehaviour
{
        private float deltaTime = 0.0f;
        [Header("显示帧数的文本控件")]
        public Text textFps;

        void Update()
        {
                deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
                float fps = 1.0f / deltaTime;
                string text = (int)fps+"";
                float col = fps / 60f;
                Color color = new Color(1, col, 1 - col);

                textFps.color = color;
                textFps.text = text;
        }
}
